﻿// Xshell Main Implementation Application - Entry Point
// 
// <copyright file="Program.cs" company="TaskyMedia LLC">
//   Copyright © 2010 TaskyMedia LLC
// </copyright>

namespace Xshell
{
    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;

    /// <summary>
    /// Main program application entry point.
    /// </summary>
    internal class Program
    {
        /// <summary>
        /// Performs the work associated with the application.
        /// </summary>
        /// <param name="args">The command line arguments.</param>
        public static void Main(string[] args)
        {
            string configPath = Xshell.Properties.Settings.Default.ConfigFilePath;

            MetadataCache metadataCache = new MetadataCache();
            XmlConfigReader configReader = new XmlConfigReader(configPath);

            configReader.SetMetadataCache(metadataCache);

            IEnumerable<IXsTaskSet> taskSets = configReader.ReadTaskSets();

            foreach (IXsTaskSet taskSet in taskSets)
            {
                if (taskSet.AreConditionsValid)
                {
                    taskSet.Execute();
                    break;
                }
            }

            Application.Run();
        }
    }
}
